package com.qing.design.patterns.factory_method.example.buttons;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class WindowsButton implements Button{

	JPanel jpanel=new JPanel();
	JFrame jFrame=new JFrame();
	JButton jButton;

	public void render() {
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JLabel jLabel=new JLabel("Hello World!");
		jLabel.setOpaque(true);
		jLabel.setBackground(new Color(235,233,126));
		jLabel.setFont(new Font("Dialog", Font.BOLD, 44));
		jLabel.setHorizontalAlignment(SwingConstants.CENTER);
		jpanel.setLayout(new FlowLayout(FlowLayout.CENTER));
		jFrame.getContentPane().add(jpanel);

		jpanel.add(jLabel);
		onClick();
		jpanel.add(jButton);

		jFrame.setSize(320, 200);
		jFrame.setVisible(true);
		onClick();
	}

	public void onClick() {
		jButton=new JButton("Exit");
		jButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				jFrame.setVisible(false);
				System.exit(0);
			}
		});
	}
}
